﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace EmployeeCheckIn
{
    public class CutString
    {
        public string cutEMP(string s)
        {
            string[] cutst = s.Split(';');
            return cutst[0];
        }
        public string cutFirsName(string s) 
        {
            string[] cutst = s.Split(';');
            return cutst[1];
        }
        public string cutLastName(string s)
        {
            string[] cutst = s.Split(';');
            return cutst[2];
        } 
        public string cutDate(string s) 
        {
            string[] cutst = s.Split(';');
            return cutst[3];
        }
        public string cutCheckIn(string s) 
        {
            string[] cutst = s.Split(';');
            return cutst[4];   
        }
        public string cutCheckOut(string s)
        {
            string[] cutst = s.Split(';');
            return cutst[5];
        }
        public string cutEMPCODE(string s) 
        {
            string[] cutst = s.Split(';');
            return cutst[6];
        }

        public DateTime dtm(string indate,string intime) 
        {
            string[] cutdate = indate.Split('/');
            string[] cuttime = intime.Split(':');
            int _day;
            int _mount;
            int _year;
            int _HH;
            int _MM;
            int _SS;
            try
            {
                _day = Convert.ToInt32(cutdate[0]);
            }
            catch (Exception)
            {

                _day = 1;
            }
            try
            {
                _mount = Convert.ToInt32(cutdate[1]);
            }
            catch (Exception)
            {

                _mount = 1;
            }
            try
            {
                if (Convert.ToInt32(cutdate[2]) > 2300)
                {
                    _year = Convert.ToInt32(cutdate[2]) - 543;
                }
                else
                {
                    _year = Convert.ToInt32(cutdate[2]);
                }
            }
            catch (Exception)
            {

                _year = 2013;
            }
            try
            {
                _HH = Convert.ToInt32(cuttime[0]);
            }
            catch (Exception)
            {

                _HH = 0;
            }
            try
            {
                _MM = Convert.ToInt32(cuttime[1]);
            }
            catch (Exception)
            {

                _MM = 0;
            }
            try
            {     
                 _SS = Convert.ToInt32(cuttime[2]);
            }
            catch
            {
                _SS = 0;
            }
            return new DateTime(_year, _mount, _day, _HH, _MM,_SS);
        }

        
    }
}